<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">
<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>MRP</title>
    <!--<f:view locale="#{mainMgb.locale}"/>-->
    <f:view oamEnableViewPool="true"/>
    <style type="text/css">
        .accordionMenu .ui-menu {
            width: 100% !important;
        }

        .accordionMenu .ui-accordion-content {
            width: 92% !important;
            padding: 0 !important;
            overflow: inherit !important;
        }

        .ui-widget {
            font-size: 12px !important;
        }

        /* default/non-selected menuitem style */
        .orders-menuitem-text .ui-menuitem-text {
            font-size: 90% !important;
        }

        .ui-dialog-titlebar {
            background-color: #2C4F6D;
        }

        /* selected menuitem style */
        .orders-menuitem-selected .ui-menuitem-text {
            font-size: 95% !important;
            font-weight: bolder !important;
        }

        .ui-inputfield[disabled], .ui-inputfield[disabled].ui-state-focus {
            border: 0 !important;
            box-shadow: none !important;
            outline: 0 !important;
        }

        .ui-panelgrid .ui-panelgrid-footer {
            text-align: center;
            padding: 2px 5px;
        }

        /*.ui-layout-unit-content{background-image:url('#{request.contextPath}/images/header_bg.png');}*/

    </style>
    <script type="text/javascript">

        PrimeFaces.locales['th'] = { isBE: true, autoConversionField: false,
            closeText: 'ปิด', prevText: 'ก่อนหน้า', nextText: 'ต่อไป', monthNames: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'มีนาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม' ], monthNamesShort: ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.' ], dayNames: ['วันอาทิตย์', 'วันจันทร์', 'วันอังคาร', 'วันพุธ', 'วันพฤหัสบดี', 'วันศุกร์', 'วันเสาร์'], dayNamesShort: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'], dayNamesMin: ['อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'], weekHeader: 'สัปดาห์', firstDay: 1, isRTL: false, showMonthAfterYear: false, yearSuffix: '', timeOnlyTitle: 'เวลาเท่านั้น', timeText: 'เวลา', hourText: 'ชั่วโมง', minuteText: 'นาที', secondText: 'วินาที', currentText: 'เวลาปัจจุบัน', ampm: false, month: 'เดือน', week: 'สัปดาห์', day: 'วัน', allDayText: 'ทุกวัน'
        };
    </script>
</h:head>
<h:body>
    <h:outputScript id="handleDialog" target="body">
        /* <![CDATA[ */
        function handleDialog(xhr, status, args, dlg) {

            if (!args.validationFailed) {
                if (args.checkBusinessFail != 'undefined')
                    if (!args.checkBusinessFail)
                        dlg.hide();
            }
        }

        function clickButton(id) {
            document.getElementById(id).click();
        }

        function selectMenuitemLink(link) {
            $("#menuSecurity").find(".ui-state-active").removeClass("ui-state-active");
            $(link).addClass("ui-state-active");
        }

        var t;

        function startTimer() {
            t = setTimeout("statusDialog.show()", 1100);
        }

        function stopTimer() {
            clearTimeout(t);
        }

        /* ]]> */
    </h:outputScript>
    <p:layout fullPage="true">
        <p:layoutUnit position="north" size="70" resizable="false"
                      style="background-image:url('#{request.contextPath}/images/header_bg.png'">
            <h:form>
                <h:commandLink action="/index.xhtml" value="Company Logo"
                               style="position:fixed;left:20px;top:10px;font-size: xx-large;text-decoration: none;"/>
                <h:commandLink action="#{loginMgb.logout}" value="Logout" style="position:fixed;right:20px;top:40px"/>
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="west" size="200" header="MENU"
                      resizable="true" collapsed="false" closable="false"
                      collapsible="true">
            <h:form>
                <p:accordionPanel styleClass="accordionMenu">
                    <p:tab title="Stock">
                        <p:menu>
                            <p:menuitem value="Stock Input"
                                        action="/modules/inv/stockIn.xhtml" update=":content"
                                        ajax="false"/>
                            <p:menuitem value="Stock Output"
                                        action="/modules/inv/stockOut.xhtml" update=":content"
                                        ajax="false"/>
                            <p:menuitem value="Balance"
                                        action="/modules/inv/balance.xhtml" update=":content"
                                        ajax="false"/>
                            <p:menuitem value="Report Stock In Summary"
                                        action="/modules/inv/reportStockInSummary.xhtml" update=":content"
                                        ajax="false"/>
                        </p:menu>
                    </p:tab>
                </p:accordionPanel>
                <p:accordionPanel styleClass="accordionMenu" activeIndex="-1">
                    <p:tab title="Security">
                        <p:menu>
                            <p:menuitem value="User" action="/modules/security/user.xhtml"
                                        update=":content" ajax="false"/>
                            <p:menuitem value="Group" action="/modules/security/group.xhtml"
                                        update=":content" ajax="false"/>
                            <p:menuitem value="Right" action="/modules/security/right.xhtml"
                                        update=":content" ajax="false"/>
                            <p:menuitem value="Permission"
                                        action="/modules/security/permission.xhtml" update=":content"
                                        ajax="false"/>
                        </p:menu>
                    </p:tab>
                </p:accordionPanel>
                <p:accordionPanel styleClass="accordionMenu" activeIndex="-1">
                    <p:tab title="System">
                        <p:menu>
                            <p:menuitem value="Jobs" action="/modules/system/job.xhtml"
                                        update=":content" ajax="false"/>
                            <p:menuitem value="Theme Switcher"
                                        action="/modules/system/themeswitcher.xhtml" update=":content"
                                        ajax="false"/>
                        </p:menu>
                    </p:tab>
                </p:accordionPanel>
                <p:accordionPanel styleClass="accordionMenu" activeIndex="-1">
                    <p:tab title="Master">
                        <p:menu>

                            <p:menuitem value="Products"
                                        action="/modules/master/products.xhtml" update=":content"
                                        ajax="false"/>
                            <p:menuitem value="Product Categories"
                                        action="/modules/master/productCategories.xhtml" update=":content"
                                        ajax="false"/>
                        </p:menu>
                    </p:tab>
                </p:accordionPanel>
                <p:selectOneMenu value="#{mainMgb.locale}" style="width:120px">
                    <p:ajax listener="#{mainMgb.changeLanguage()}"/>
                    <f:selectItem itemLabel="Thai" itemValue="th"/>
                    <f:selectItem itemLabel="English" itemValue="en"/>
                </p:selectOneMenu>

                <!-- 					<p:outputLabel value="#{sessionBean.sessionId}"/> -->
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="center">
            <h:panelGroup id="content" layout="block" style="margin: 0 auto;">
                <center>
                    <ui:insert name="body">Content</ui:insert>
                </center>
            </h:panelGroup>
            <pe:ajaxErrorHandler type="java.lang.Exception" button="Close">
                <f:facet name="title">
                    Error:<span style="color: red;">{error-name}</span>
                </f:facet>
                <f:facet name="msgbody">
                    <div>
                        <h:form>
                            <p:tabView>
                                <p:tab title="Message">
                                    <h:panelGrid columns="2">
                                        <h:outputLabel value="Error message:"/>
                                        <h:outputText value="{error-message}"
                                                      style="font-size: 1.2em;color:navy;"/>
                                        <h:outputLabel value="Server name:"/>
                                        <h:outputText value="{error-hostname}"
                                                      style="font-size: 1.2em;color:navy;"/>
                                    </h:panelGrid>
                                </p:tab>
                                <p:tab title="DetailError">
                                    <div style="overflow: auto; height: 300px; width: 700px;">{error-stacktrace}</div>
                                </p:tab>
                            </p:tabView>
                        </h:form>
                    </div>
                </f:facet>
            </pe:ajaxErrorHandler>
            <p:ajaxStatus onstart="startTimer();"
                          onsuccess="statusDialog.hide(); stopTimer();"
                          onerror="errorDialog.show(); stopTimer(); statusDialog.hide()"/>
            <p:dialog modal="true" widgetVar="statusDialog" header="Loading..."
                      draggable="false" closable="false">
                <p:graphicImage value="/images/ajax-loading-bar.gif"/>
            </p:dialog>
            <p:dialog modal="true" widgetVar="errorDialog" header="Error"
                      draggable="false" closable="false">
                Key 'F5' for Reload
            </p:dialog>
        </p:layoutUnit>
    </p:layout>
</h:body>
</html>
